//
//  MenuScene.m
//  cocos2dappfwk
//
//  Created by Development on 21/07/2010.
//  Copyright Lowrie Associates Ltd 2010. All rights reserved.
//

#import "MenuScene.h"
#import "MenuItemComplete.h"
#import "LoopingMenu.h"
#import "ModalAlert.h"
#import "AboutScene.h"

@implementation MenuLayer

+(id) scene
{
	CCScene *scene = [CCScene node];
	MenuLayer *layer = [MenuLayer node];
	[scene addChild: layer];
	return scene;
}

-(id) init
{

	if( (self=[super init] )) {
		MenuItemComplete *mnuKaleidoscope = [[MenuItemComplete alloc] initFromImage:@"mnuMain.png" title:[CCLabel labelWithString:@"Main" fontName:@"marker felt" fontSize:24] target: self selector: @selector(onMain:)];
		MenuItemComplete *mnuAbout = [[MenuItemComplete alloc] initFromImage:@"mnuAbout.png" title:[CCLabel labelWithString:@"About" fontName:@"marker felt" fontSize:24] target: self selector: @selector(onAbout:)];
		MenuItemComplete *mnuQuit = [[MenuItemComplete alloc] initFromImage:@"mnuQuit.png" title:[CCLabel labelWithString:@"Quit" fontName:@"marker felt" fontSize:24] target: self selector: @selector(onQuit:)];
		LoopingMenu *menu = [LoopingMenu menuWithItems:mnuKaleidoscope, mnuAbout, mnuQuit, nil];
		[menu alignItemsHorizontallyWithPadding:30];
		[self addChild:menu];
		
		CCLabel * l = [CCLabel labelWithString:@"Main Menu" fontName:@"marker felt" fontSize:28];
		l.position = ccp(160,420);
		[self addChild:l];
		
	}
	return self;
}

-(void)onMain: (id) sender
{
}

-(void)onAbout: (id) sender
{
	[[CCDirector sharedDirector] replaceScene:[CCFlipAngularTransition transitionWithDuration:0.5f scene:[AboutScene scene]]];
}

-(void)onQuit: (id) sender
{
	if (createModalAlert( @"Quit", @"Are you sure you want to exit?", @"No", @"Yes")==1)	//Exit
		exit(0);
}

- (void) dealloc
{
	[super dealloc];
}

@end
